﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using BL;
using System.Web.Script.Serialization;
using System.ServiceModel.Activation;
using unigator.Responses;

namespace services
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]    
    public class App : IApp
    {
        Manager m_Manager;

        public App()
        {
            m_Manager = new Manager();
        }

        public List<Point> FindPointByName(string name)
        {
            List<Point> n = new List<Point>();

            var result = m_Manager.FindPointByName(name);

            foreach (var item in result)
            {
                n.Add(new Point(item));
            }

            return n;
        }

        public List<Node> FindPathFromTo(int from, int to)
        {
            List<Node> n = new List<Node>();

            var result = m_Manager.FindPathFromTo(from, to);

            foreach (var item in result)
            {
                n.Add(new Node(item));
            }

            return n;
        }

        public void CheckExistingVertexInRange(double longtitude, double latitude)
        {
            m_Manager.CheckExistingVertexInRange(longtitude, latitude);
        }

        public void FindVertexByLongLat(double longtitude, double latitude)
        {
            m_Manager.FindVertexByLongLat(longtitude, latitude);
        }

        public void AddVertex(double longtitude,double latitude)
        {
            m_Manager.AddVertex(longtitude,latitude);
        }

        public void AddIntrestPoint(int vertex_id, string name, string text)
        {
            m_Manager.AddIntrestPoint(vertex_id, name, text);       
        }

        void UpdateIntrestPoint(int id, String pointName, String text)
        {
            m_Manager.UpdateIntrestPoint(id, pointName, text);
        }

        public void AddEdge(int inVertex, int outVertex, double weight)
        {
            m_Manager.AddEdge(inVertex,outVertex, weight);
        }

        public void CalculateDistance(double long1, double long2,double lat1 , double lat2)
        {
            Vertex inVertex = new Vertex(1,long1,lat1);
            Vertex outVertex = new Vertex(2, long2, lat2);
            double ret = m_Manager.CalculateDistanceBetweenTwoVertices(inVertex, outVertex);
        }

        public void GeneratePaths()
        {
            m_Manager.GeneratePaths();
        }
    }
}
